<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" th:href="@{/assets/css/colorbox.css}" />
<head th:include="fragments/head::header" />
<style>
    .error {
        color: #F00
    }
</style>
<body>
<div th:include="fragments/top::top"></div>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <div th:include="fragments/left::left" class="sidebar" id="sidebar"></div>
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i> <a href="/main">首页</a></li>
                    <li>合作机构信息</li>
                    <li>合作机构信息列表</li>
                </ul>
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-12">
                                <h3 class="header smaller lighter blue">合作机构信息列表</h3>
                                <div class="table-header">
                                    <form class="form-inline">
                                        <div class="form-group">
                                            <label>机构名称：</label>
                                            <input type="text" id="input_agencyName" class="form-control input-sm" placeholder="" style="width:100px;"/>
                                            <label>机构类型：</label>
                                            <select id="select_agencyType" class="form-control input-sm" style="width:100px;">
                                                <option value="-1">-请选择-</option>
                                                <option value="1">接机</option>
                                                <option value="2">保险</option>
                                                <option value="3">监护</option>
                                                <option value="4">住宿</option>
                                                <option value="5">院校</option>
                                            </select>
                                        </div>
                                        <button type="button" id="query" class="btn btn-success ">查询</button>
                                        <button type="reset" class="btn btn-warning">清空</button>
                                        <a data-toggle="modal" class="btn btn-info pull-right" href="javascript:void(0);" onclick="toAddURL();">添加合作机构</a>
                                    </form>
                                </div>
                                <div class="table-responsive">
                                    <div id="alert" class="alert alert-success" style="display: none;" role="alert">
                                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                        <span id="alertText"></span>
                                    </div>
                                    <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th class="hide">id</th>
                                            <th>机构类型</th>
                                            <th>合作机构名称</th>
                                            <th>所属国家</th>
                                            <th>操作人</th>
                                            <th>操作日期</th>
                                            <th class="hidden-480">操作</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div th:include="fragments/bottom::bottom"></div>
    </div>
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content"></div>
    </div>
</div>
<div th:include="fragments/js::js"></div>
<script th:src="@{/assets/js/jquery.validate.min.js}"></script>
<script th:src="@{/assets/js/jquery.validate.zh-CN.js}"></script>
<!-- page specific plugin scripts -->
<script th:src="@{/assets/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/assets/js/jquery.dataTables.bootstrap.js}"></script>
<script th:src="@{/assets/js/temp.js}" charset="UTF-8"></script>
<!--图片查看器-->
<script th:src="@{/assets/js/jquery.colorbox-min.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script type="text/javascript">
    <!--
    var oTable1;
    jQuery(function($) {
        oTable1 = $('#sample-table-2').dataTable({
            "sScrollY": "380px",
            "bFilter" : false,//是否使用搜索
            "bProcessing" : true,
            "bDeferRender" : true,//
            "sPaginationType" : "bs_normal",//分页样式
            "bRetrieve" : true,//是否调用后台
            "bServerSide" : true,//是否以后台分页
            "sAjaxSource" : "/agency/list/query",//请求路径
            "fnServerData" : function(sSource, aoData, fnCallback) {
                var agencyName = $("#input_agencyName").val() == ""?null:$("#input_agencyName").val();
                var agencyType = $("#select_agencyType option:selected").val() == -1?null:$("#select_agencyType option:selected").val();
                if(agencyName != null)
                    aoData.push({"name":"agencyName","value":agencyName });
                if(agencyType != null)
                    aoData.push({"name":"agencyType","value":agencyType });
                $.ajax({
                    "dataType" : 'json',
                    "type" : "GET",
                    "url" : sSource,
                    "data" : aoData,
                    "success" : fnCallback
                });
            },
            "aaSorting" : [ [ 1, "desc" ] ],
            "aoColumns" : [
                {"sClass": "center", "bVisible": false, "mData": "id"},
                {"sClass": "center", "bSortable": false, "mData": "agencyType_string"},
                {"sClass": "center", "bSortable": false, "mData": "agencyName"},
                {"sClass": "center", "bSortable": false, "mData": function (data) {
                    var html = "<a href='javascript:void(0);' title='"+data.nationNameMore+"'>"+data.nationName+"</a>"
                    return html;
                }},
                {"sClass": "center", "bSortable": false, "mData": "operatorName"},
                {"sClass": "center", "bSortable": false, "mData": "createTime_string"},
                {"sClass" : "center", "bSortable" : false, "mData" : function (data) {
                    var styleDiv='<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">';
                    var check='<a class="blue" href="javascript:void(0);" onclick="toDetail(' + data.id + ')"><i class="icon-zoom-in bigger-130"></i></a>';
                    var editOperation= '<a class="green" href="javascript:void(0);" onclick="toEditURL('+data.id+')"><i class="icon-pencil bigger-130"></i></a>';
                    var disableOperation = '<a href="javascript:void(0);" onclick="enableData('+data.id+')">启用</a>';
                    if(data.enableStatus == "1"){
                        disableOperation = '<a  href="javascript:void(0);" onclick="disableData('+data.id+')">禁用</a>';
                    }
                    return styleDiv+check+editOperation+disableOperation;
                }}
            ],
            "oLanguage" : {
                "sLengthMenu" : "每页 _MENU_条 ",
                "sZeroRecords" : "对不起，查询不到任何相关数据",
                "sInfo" : "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录 ",
                "sInfoEmpty" : "显示 0 到 0 条，共 0 条记录",
                "sInfoFiltered" : "数据表中共为 _MAX_ 条记录)",
                "sProcessing" : "正在加载中...",
                "sSearch" : "搜索",
                "sUrl" : "", //多语言配置文件，可将oLanguage的设置放在一个txt文件中，例：Javascript/datatable/dtCH.txt
                "oPaginate" : {
                    "sFirst" : "第一页",
                    "sPrevious" : " 上一页 ",
                    "sNext" : " 下一页 ",
                    "sLast" : " 最后一页 "
                }
            }
            //多语言配置
        });
        $("#query").click(function() {
            oTable1.fnDraw();
        })
    })
    function toAddURL() {
        window.open("/agency/addPage",target="_self");
    }
    function toDetail(id) {
        window.open("/agency/detailPage?id=" + id,target="_self");
    }
    function toEditURL(id){
        window.open("/agency/editPage?id=" + id,target="_self");
    }

    function enableData(id) {
        layer.confirm('您确定启用此数据吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("/agency/editEnableStatus",{"id":id,"enableStatus":"1"},function(data, status){
                if(data){
                    window.location.reload();
                }
            });
        }, function(){
            parent.layer.close();
        });

    }
    function disableData(id) {
        layer.confirm('您确定启用此数据吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("/agency/editEnableStatus",{"id":id,"enableStatus":"0"},function(data, status){
                if(data){
                    window.location.reload();
                }
            });
        }, function(){
            parent.layer.close();
        });

    }
    -->
</script>
</body>
</html>